﻿@using Abs.Core.Models.Blog
@using Abs.Core.Models.User
@model Abs.Core.Models.Blog.Post

@{
    ViewBag.Title = "Details";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@Html.ActionLink("Back to List", "Index")
<br/> <br/>

<fieldset>
    <legend>@this.Model.Title</legend>
    
    <div class="display-field">
        @Html.DisplayFor(model => model.ContentMessage)
    </div>
    
    <div>
        <br/><br/>
        <b>@this.Model.User.Name</b> <br/>
        @this.Model.Date
    </div>

    <div><hr/></div>

    <div class="display-label"><h3>Follow the Discussion</h3></div>
    

    <div class="display-field">
        @foreach(var comment in Model.Comments)
        {
            @comment.ContentMessage <br/>
            <b>@comment.User.Name</b> <span> | </span>
            @comment.Date
            <br/><br/>
        }
    </div>
</fieldset>
<p>
    @Html.ActionLink("Comment", "Create", "Comment", new {postId = this.Model.PostId}, null)

    @if (String.IsNullOrEmpty((string) this.Session["Email"]) || 
                       (int)this.Session["Role"] == (int)RoleEnum.Admin)
    {
        <span> | </span>
        @Html.ActionLink("Edit", "Edit", new {id = Model.PostId}) 
        <span> | </span>
    }
    @Html.ActionLink("Back to List", "Index")
</p>
